<?php

namespace app\index\controller;

use app\index\controller\Base;
use think\Db;
use think\Session;

class Finance extends Base
{
    /**
     * 奖金明细
     * @return mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function FinanceList(){
        //找出对应的记录
        $Type = Param('Type');
        $this->assign('Type',$Type);
        // $FinanceList = Db::name('finance')->where(['user_id'=>Session::get('user_id'),'type'=>$Type])->order("add_time desc")->select();
        $FinanceList = Db::name('finance')->where(['user_id'=>Session::get('user_id')])->order("add_time desc")->select();
        foreach ($FinanceList as $k=>$v){
            $UserInfo = UserInfo(['id'=>$FinanceList[$k]['from_id']]);
            $FinanceList[$k]['username'] = $UserInfo['username'];
        }
        $this->assign('FinanceList',$FinanceList);
        return $this->fetch('FinanceList');
    }


    /**
     * 提现记录
     * @return mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function WithdrawList(){

        //提现记录
        $WithdrawList = WithdrawList(['user_id'=>Session::get('user_id')]);
        $this->assign('WithdrawList',$WithdrawList['WithdrawList']);
        //分页
        $this->assign('Page',$WithdrawList['Page']);

        return $this->fetch('WithdrawList');
    }

    /**
     * 汇率
     * @return mixed
     */
    public function Exchange(){
        return $this->fetch('Exchange');
    }
}
